package net.sourceforge.peertwitter.core.messaging;

import net.sourceforge.peertwitter.scamp.messaging.ScampMessage;
import rice.p2p.commonapi.Id;
import rice.p2p.commonapi.NodeHandle;

public class TweetMessage extends ScampMessage {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6133076267243883412L;
	private final String message;

	public TweetMessage(NodeHandle sender, long timestamp, String message) {
		super(sender.getId(), sender, timestamp);
		this.message = message;
	}

	public String getMessage() {
		return message;
	}
	
	
	
	public Id getId() {
		return getSender().getId();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((message == null) ? 0 : message.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		TweetMessage other = (TweetMessage) obj;
		if (message == null) {
			if (other.message != null)
				return false;
		} else if (!message.equals(other.message))
			return false;
		return true;
	}

}
